package com.hanamaki.homework;

import java.util.Scanner;

public class Demo01 {


    public static void main(String[] args) {
        System.out.println("计算12+·····92的值：" + first());
        System.out.println("计算50+·····100的偶数值：" + odd_sum());
        System.out.println("计算阶乘：" + f(5));
        print100();
        print100_odd();
        even();
        personYear();
        System.out.println("蜗牛一共爬了多少天:" + paDay());

    }

    public static int first() {
        int sum = 0;
        for (int i = 12; i < 100; i += 10) {
            sum += i;
        }
        return sum;
    }

    public static int odd_sum() {
        int sum = 0;
        for (int i = 50; i <= 100; i++) {
            if (i % 2 == 0) {
                sum += i;
            }
        }
        return sum;
    }

    public static int f(int n) {
        if (n == 1) {
            return 1;
        } else {
            return n * f(n - 1);
        }
    }

    public static void print100() {
        for (int i = 1; i <= 100; i++) {
            System.out.print(i + "\t");
        }
        System.out.println();
    }

    public static void print100_odd() {
        for (int i = 1; i <= 100; i++) {
            if (i % 2 == 0) {
                System.out.print(i + "\t");
            }
        }

        System.out.println();
    }

    // 3   3  1 5   5   3  1
    public static void even() {
        System.out.println("请输入一个正整数！");
        Scanner scanner = new Scanner(System.in);
        int i = scanner.nextInt();
        for (int a = i; a >= 1; a--) {
            if (a % 2 != 0) {
                System.out.print(a + "\t");
            }
        }
        System.out.println();

    }

    public static void personYear() {
        int year = 2006;
        int personCount = 8;
        while (personCount <= 70) {
            year++;
            personCount += personCount * 0.25;
        }
        System.out.println(year);
    }

    public static int paDay() {
        int a = 30;
        int b = 0;
        int day = 0;
        // i 是第一天
        for (int i = 1; i > 0; i++) {
            // 第一天开始了
            b += 3;
            if (b >= a) {
                day = i;
                break;
            } else {
                b -= 2;
            }
        }
        return day;
    }





}
